package test1.Car;

import java.util.Scanner;

public class cartest {
    public static void main(String[] args) {
        //创建一个数组来存储汽车的三个对象
        car[] arr=new car[3];
        for (int i = 0; i < arr.length; i++) {
            Scanner sc=new Scanner(System.in);
            //创建汽车对象
            car c=new car();
            System.out.println("请输入汽车品牌");
            String brand=sc.next();
            c.setBrand(brand);
            System.out.println("请输入价格");
            int price=sc.nextInt();
            c.setPrice(price);
            System.out.println("请输入汽车的颜色");
            String color= sc.next();
            c.setColor(color);
            //把汽车对象放入索引中
            arr[i]=c;
        }
        //遍历数组，获得属性值
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            car car = arr[i];
           // sum = sum + car.getPrice(); 获得总的价格以便求平均值
            System.out.println(car.getBrand() + "，" + car.getColor() + "," + car.getPrice());
        }
        // int avg=sum/arr.length;
        //sout;
    }
}
